const {createRole,getRoleTable}  = require("../service/role.service")
const {RoleSelectError} = require("../consitant/err.type");

class RoleController {
    async createRoleController (ctx,next) {
        try{
            console.log(ctx.request.body.is_state)
            const {role_name,jurisdiction,is_state} = ctx.request.body

            const res = await createRole(role_name,jurisdiction,is_state)
            ctx.body = {
                code:0,
                message:'添加成功',
                result:res
            }
        }catch (e){
                console.log(e)
        }
    }
    async getRoleController(ctx,next) {
        try {
            const res = await getRoleTable()

            ctx.body = {
                code:0,
                message:'查询成功',
                result:res
            }
        }catch (e) {
            console.error(e)
            ctx.app.emit('error',RoleSelectError,ctx)
        }
    }
}

module.exports = new RoleController()
